<!-- Generated automatically from an XML file of the same name.
     Copyright: Stephen J. Sangwine and Nicolas Le Bihan, 2008-2010.
--><html><head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
   <title>diag :: Functions (Quaternion Toolbox Function Reference)
</title><link rel="stylesheet" href="qtfmstyle.css" type="text/css"></head><body><h1>Quaternion Function Reference</h1><h2>diag</h2>
<p>Diagonal matrices and diagonals of a matrix.<br>(Quaternion overloading of standard MATLAB&reg; function)
</p>
<h2>Syntax</h2><p><tt>Y = diag(X, K)</tt></p>
<h2>Description</h2>
<p>
<tt>diag(X)</tt> returns the diagonal elements of the quaternion matrix
<tt>X</tt>. If <tt>X</tt> is a vector, <tt>diag(X)</tt> constructs
a quaternion diagonal matrix using the elements of the vector as the
diagonal elements. The second parameter must be a scalar integer indicating
the main diagonal (K = 0), super diagonals (K &gt; 1), or sub diagonals (K &lt; 1).
</p>

<h2>Examples</h2>
<pre>
&gt;&gt; diag([qi, qj, qk])
 
ans = 3x3 pure quaternion array
 
&gt;&gt; show(ans)
 
ans.X =
 
     1     0     0
     0     0     0
     0     0     0

ans.Y =
 
     0     0     0
     0     1     0
     0     0     0

ans.Z =
 
     0     0     0
     0     0     0
     0     0     1
</pre>

<h2>See Also</h2>MATLAB&reg; function: <a href="matlab:doc diag">diag</a><br>QTFM functions: <a href="blkdiag.html">blkdiag</a>, <a href="tril.html">tril</a>, <a href="triu.html">triu</a><br>
<h4>&copy; 2008-2010 Stephen J. Sangwine and Nicolas Le Bihan</h4><p><a href="license.html">License terms.</a></p></body></html>